<?php

/**
 * Mapper for schemata table model
 */
class Default_Model_SchemataMapper
{
    protected $_dbTable;

	public function setDbTable($dbTable)
	{
            if (is_string($dbTable)) {
                $dbTable = new $dbTable();
            }

            if (!$dbTable instanceof Zend_Db_Table_Abstract) {
                throw new Exception('Invalid table data gateway provided');
            }

            $this->_dbTable = $dbTable;

            return $this;
	}

	public function getDbTable()
	{
            if (null === $this->_dbTable) {
                $this->setDbTable('Default_Model_DbTable_Schemata');
            }
            return $this->_dbTable;
	}

        /**
         * Get data bases names
         * @return array
         */
        public function getAllDataBases()
        {
            $sql = 'SHOW DATABASES';
            return $this->getDbTable()->getAdapter()->fetchAll($sql);
        }
}